<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/3
 * Time: 12:53
 */
include "config.php";
if($_SERVER["REQUEST_METHOD"]=="POST"){
    $u_id=isset($_POST["u_id"])?$_POST["u_id"]:"";
    $sqlcarts="select * from carts where u_id=?;";
    $stmt=$connection->prepare($sqlcarts);
    $stmt->bind_param("i",$u_id);
    $stmt->execute();
    $result=$stmt->get_result();
    $stmt->close();
    $connection->close();
    $arr=array();

    while($row=$result->fetch_assoc()){
        array_push($arr,$row);
    }

    print_r(json_encode(array("status"=>1,"mas"=>"获取carts库成功","data"=>$arr)));

}
else{
    print_r(json_encode(array("status"=>0,"mas"=>"不支持GET请求")));
}